package compendiumAid.presentation.elementView
{
	import compendiumAid.application.AlwaysViewElementEvent;
	import compendiumAid.application.Element;
	import compendiumAid.application.loadElement.LoadElementEvent;
	import compendiumAid.application.ViewElementEvent;
	import compendiumAid.domain.model.ApplicationModel;
	import compendiumAid.presentation.PresentationModel;
	
	[ManagedEvents(names="LoadElementEvent, AlwaysViewElementEvent")]
	public class ElementViewPM extends PresentationModel
	{
		[Inject]
		[Bindable]
		public var model:ApplicationModel;
		
		[Bindable]
		public var element:Element;
		
		[Bindable]
		public var expandView:Boolean = false;
		
		[MessageHandler]
		public function viewElement(event:ViewElementEvent):void
		{
			expandView = true;
			
			element = new Element(event.elementVO);
			dispatcher(new LoadElementEvent(element));
		}
		
		public function alwaysViewElement(value:Boolean):void
		{
			dispatcher(new AlwaysViewElementEvent(value));
		}
	}
}